package cn.qzuie.smart.module.dorm.dal.mysql.assettype;

import java.util.*;

import cn.qzuie.smart.framework.common.pojo.PageResult;
import cn.qzuie.smart.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.qzuie.smart.framework.mybatis.core.mapper.BaseMapperX;
import cn.qzuie.smart.module.dorm.dal.dataobject.assettype.AssetTypeDO;
import org.apache.ibatis.annotations.Mapper;
import cn.qzuie.smart.module.dorm.controller.admin.assettype.vo.*;

/**
 * 资产类型 Mapper
 *
 * @author 吴宗波
 */
@Mapper
public interface AssetTypeMapper extends BaseMapperX<AssetTypeDO> {

    default List<AssetTypeDO> selectList(AssetTypeListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AssetTypeDO>()
                .likeIfPresent(AssetTypeDO::getName, reqVO.getName())
                .orderByDesc(AssetTypeDO::getId));
    }

	default AssetTypeDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(AssetTypeDO::getParentId, parentId, AssetTypeDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(AssetTypeDO::getParentId, parentId);
    }

}